#ifndef VIDEOWAPPER_H_
#define VIDEOWAPPER_H_

#include <stdint.h>
#include <string>
#include <thread>
#include "NetMgr.h"
#include "pcapParse.h"
#include "RtpToPcap.h"

struct VideoWapperParams {
	
	uint16_t m_local_port = 0;
	uint16_t m_remote_port = 0;
	std::string m_remote_ip = "";
	std::string m_local_ip = "0.0.0.0";

	int8_t m_ip_type = 0; // 0-udp 1-tcp

	int8_t m_video_codec = 0; // 0-h264 1-h265

	uint8_t m_payloadType = 0;

	std::string m_pcap_sender = "";
	std::string m_pcap_receive = "";

};

#define RevBufferSize 1024*32

class VideoWapper
{
public:
	VideoWapper();
	~VideoWapper();
	int32_t Connect();
	void ReleaseConnect();
	int32_t SetRemoteSDP(VideoWapperParams &oVideoWapperParams);

	int32_t IncomingRtp(const int8_t * data, int32_t len);

	void ThreadFun();
private:

	bool TimerFun();
	
	void OnReadCallBack();

	VideoWapperParams m_VideoWapperParams;
	int socket_fd = 0;
	std::shared_ptr<WorkerThreadN> m_task_scheduler;
	std::vector<char> m_readBuffer;

	struct sockaddr_storage m_remote_addr;

	int64_t m_iTimerId = -1;

	CRtpManage m_CRtpManage;
	bool m_bExit = false;
	std::thread* m_thread = NULL;

	RtpToPcap* m_RtpToPcap = NULL;
};


#endif